#include "circleitem.h"
#include <QGraphicsScene>
#include "padgraphicsview.h"

CircleItem::CircleItem(float cx, float cy, float radius, QGraphicsScene *scene, PadGraphicsView *parent) :
    QGraphicsEllipseItem(nullptr), x(cx), y(cy), r(radius), parentScene(scene)
{
    adjustRect();
    this->setBrush(QBrush(QColor(214, 207, 154)));
    connect(this, SIGNAL(deleteItSignal(QGraphicsItem*)), parent, SLOT(deleteItem(QGraphicsItem*)));
}



void CircleItem::getSmaller()
{
    r -= 2;
    if(r < 0) {
        parentScene->removeItem(this);
        deleteItSignal(this);
    }
    else {
        adjustRect();
    }
}

void CircleItem::adjustRect()
{
    this->setRect(x - r, y - r, 2 * r, 2 * r);
}
